<?php
/*
 * * etc: 管理员控制器 HTML
 * * author: Deepe
 * * version: v 0.1
 */

namespace app\controllers\admin;

use Core\Controller;
use Exception;

class CUser extends Controller
{

    function __construct()
    {
        $func = $_REQUEST ['func'];
//        $lib = loadLibrary('Mytp');
//        if (!isset ($_SESSION ['user']['admin_id']) && $func != "login") {
//            echo "<script>alert('请先登录!');</script>";
//            $lib->assign("baseurl", config_item('base_url'));
//            $lib->tp("signin");
//            exit ();
//        }
    }

    // 进入修改密码页面
    function modifyPwd()
    {
        $lib = loadLibrary("Mytp");
        // 赋值
        $lib->assign("baseurl", config_item('base_url'));

        $lib->tp("modifypwd");
    }
//?admin=admin&func=test
    function test()
    {
        echo "Admin-Test";
    }
    // 功能模块：管理员的首页
    // 访问地址：index.php?admin=user&func=index
    function index()
    {
        $id = isset($_SESSION ['user'] ['admin_id']) ? $_SESSION ['user'] ['admin_id'] : -1;
        $authorityModel = $this->loadAdminModel('authority', true);
        $resultMaster = $authorityModel->searchMaster($id);

        $result = $authorityModel->searchIsAuthority($resultMaster);

        $lib = loadLibrary('Mytp');
        // 赋值
        $lib->assign("baseurl", config_item('base_url'));
        // 用户SESSION
        $lib->assign("user", $_SESSION ['user']);
        // //当前的Action
        $lib->assign("admin", $_REQUEST ['admin']);

        $lib->assign("result", $result);
        // 渲染页面
        $lib->tp("index");
    }


}

?>